package com.fancy.mobileschool.ui;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.ActionBar;

import com.fancy.mobileschool.MyConfiguration;
import com.fancy.mobileschool.R;
import com.fancy.mobileschool.ui.fragment.StudentAttendFragment;
import com.fancy.mobileschool.ui.fragment.TeacherAttendFragment;

public class AttendActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_attend);

        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment fragment = fragmentManager.findFragmentByTag(MyConfiguration.type);

        if (fragment == null) {
            if (MyConfiguration.type.equals("student")) {
                fragment = new StudentAttendFragment();
                fragmentManager.beginTransaction()
                        .add(R.id.attend_fragment_container, fragment, "student")
                        .commit();
            }
            else {
                fragment = new TeacherAttendFragment();
                fragmentManager.beginTransaction()
                        .add(R.id.attend_fragment_container, fragment, "teacher")
                        .commit();
            }

        }

    }

}
